<script language="javascript">
    function change_page(i)	 {

        location.href='<?php echo PATH?>/administrator/product/index/'+i;

    }
    function uncheck(){
        for (i = 0; i < frm.length; i++)
            if (frm[i].type == "checkbox") //Kiểm tra xem có phải là checkbox ?
                if (frm[i].checked)
                    frm[i].checked = false
                else
                    frm[i].checked = true;
    }
</script>



<div class="Main_Header" align="center">QUẢN LÝ Sản Phẩm</div>
<form id="form1" name="frmtimkiem" method="post" action="<?=PATH?>/administrator/product/search">
    <table width="100%" height="62" cellpadding="0" cellspacing="0" border="0" style="border: none">
        <tr style="border: none">

            <td width="59%" align="center">
                <div style="width: 40%;float: left;font-weight: bold;">
                    Tìm kiếm sản phẩm:


                <input name="pname" type="text" id="tk" style="color:#CCCCCC" onfocus="if(this.value=='Nhập tên sản phẩm') {this.value=''; this.style.color='red'}" onblur="if(this.value=='') {this.value='Nhập tên sản phẩm'; this.style.color='#CCCCCC'}" value="Nhập tên sản phẩm" />
                </div>
                    <div class="button" style="float: left;"><input type="submit" name="Search" value="Tìm" /></div>

                </td>
        </tr>
    </table>
</form>
<form method="post" action="" name="frmmenu">


    <table width="750" border="0" cellspacing="2" cellpadding="2"  align="center" >
        <tr height="22px">


            <td><select name="category" class="input_text"  onchange="change_page(this.value);">
                <option value="">---Tất cả---</option>

    <?
     foreach($this->listmenu as $key=>$value)

    {
        if($this->cate==$value->pfid)
        {
            ?>
            <option value="<?=$value->pfid?>" selected="selected"><?=$value->pfname?></option>
            <?
        }
        else
        {
            ?>
            <option value="<?=$value->pfid?>"><?=$value->pfname?></option>
            <?
        }
    }
    ?>
            </select></td>

            <td width="59%" align="center" class="button">

                <input  type="button" onClick="location.href='<?=PATH?>/administrator/product/addproduct'"  value="Thêm sản phẩm" />
            </td>

        </tr>
    </table>
</form>
    <table style="border-collapse: collapse;"  align="center" width="750" border="1" bordercolor="#bbbbbb" cellpadding="1" cellspacing="1" >

        <form method="post" name="frm" action="">



            <tr>
                <td width="5%" height="27" ><div align="center">#ID</div></td>
                <td width="20%" >TIÊU ĐỀ </td>
                <td width="10%" ><div align="center">Hình ảnh </div></td>
                <td width="15" align="center">Giá</td>
                <td width="10%" ><div align="center">Xem/Sửa</div></td>
                <td width="10%" ><div align="center">Ngày đăng</div></td>
                <td width="10%" ><div align="center">Trạng Thái</div></td>
                <td width="40%" ><div align="center">Bình luận mới nhất</div></td>
            </tr>
            <?php if (count($this->listpro))
        {
         foreach($this->listpro as $key=>$value)
{

?>
    <tr>
        <td  height="15"  align="center" >
         <input  type="checkbox" name="element[]" value="<?=$value->pid?>" />		</td>
        <td   ><?=$value->pname?></td>
        <td   ><div align="center"><img src="<?=PATH?>/media/images/products/<?=$value->picture?>" height="40" width="50" border="0" /></div></td>
        <td align="center"><?=number_format($value->price,0,".",",")?></td>
        <td  align="center"><a href="/mymvc/administrator/product/detail/<?=$value->pid?>">Chi tiết</a></td>
        <td  align="center"><?=date('d-m-Y',strtotime($value->postdate))?></td>
        <td  align="center"><?=($value->status==1?'Hiện':'Ẩn')?></td>
        <td align="center"><?=$value->title?>....<a href="<?=PATH?>/administrator/product/comment">>>Xem tiếp>></a></td>
    </tr>
    <?php }?>
            <tr>

                <td align="center" colspan="8" height="30" class="button">
                    <input type="button" value="Chọn tất cả" onClick="uncheck()">
                    <input type="submit"   onClick="return confirm('Bạn có chắc không ?');" value="Xóa đã chọn" name="ItemDel">
                    	</td>

            </tr>

            <?php }
            else {?>

               <tr><td colspan="7" align="center" style="color: red;">Không có sản phẩm nào cả</td></tr>
        <?}
        ?>
            </form>
        </table>